{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Populating the interactive namespace from numpy and matplotlib\n"
     ]
    }
   ],
   "source": [
    "from geoscilabs.dcip.CondUtils import ColeColePelton, vizColeCole\n",
    "from geoscilabs.dcip.FreqtoTime import transFilt\n",
    "import matplotlib\n",
    "from ipywidgets import interact, FloatText, FloatSlider, ToggleButtons\n",
    "from IPython.display import display\n",
    "%pylab inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "matplotlib.rcParams['font.size'] = 16"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Complex conductivity and resistivity"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Purpose\n",
    "\n",
    "Using a simple Cole-Cole model, we parameterize complex resistivity with four parameters: resistivity at zero frequency ($\\rho_0$), chargeability($\\eta$), time constant ($\\tau$), and frequency dependence ($c$). Based upon those parameters, we understand how resistivity and conductivity changes when medium is chargeable both in frequency domain and time domain."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Set up\n",
    "\n",
    "Pelton's Cole-Cole model for resistivity and conductivity can be written as \n",
    "\n",
    "$$ \\rho(\\omega) = \\rho_0 \\Big[1 - \\eta \\Big(1-\\frac{1}{1+(\\imath\\omega\\tau)^c}\\Big) \\Big] $$\n",
    "\n",
    "and\n",
    "\n",
    "$$ \\sigma(\\omega) = \\sigma_{\\infty}\\Big(1-\\frac{\\eta}{1+(1-\\eta)(\\imath\\omega\\tau)^c} \\Big) $$\n",
    "\n",
    "respectively. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Cole-Cole app\n",
    "\n",
    "## Parameters\n",
    "\n",
    "- $\\sigma_1$: Conductivity of the first layer (S/m)\n",
    "\n",
    "- $\\sigma_2$: Conductivity of the first layer (S/m)\n",
    "\n",
    "- $f$ (Hz): Frequency (Hz)\n",
    "\n",
    "- Type: \n",
    "\n",
    "    - Reflection: Transmission power as a function of incident angle    \n",
    "    - Transmission: Transmission power as a function of incident angle    \n",
    "    - Angle: relationship between $\\theta_i$ and $\\theta_t$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "21a4cf256d864f05845b8495ac5be698",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(ToggleButtons(description='sigres', options=('sigma', 'resis'), value='sigma'), FloatSli…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<function geoscilabs.dcip.CondUtils.vizColeCole(sigres='sigma', eta=0.1, tau=0.1, c=0.5, t1=800, t2=1400)>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "interact(vizColeCole, eta=FloatSlider(min=0.1, max=0.5, step=0.05, value=0.4), \n",
    "         tau=FloatText(value=0.1), \n",
    "         c=FloatSlider(min=0.1, max=1., step=0.1, value=0.5), \n",
    "         sigres = ToggleButtons(options=['sigma','resis']), \n",
    "         t1=FloatText(value=800), \n",
    "         t2=FloatText(value=1400),          \n",
    "        )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  },
  "widgets": {
   "state": {
    "6a2fcd9221824e92aa1f285d67c9e8b4": {
     "views": [
      {
       "cell_index": 5
      }
     ]
    }
   },
   "version": "1.2.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
